

import './time-local.less';
import {getNowFormatDate,getWeekDate} from '@/utils/time'
import { useState } from "react";

const TimeLocal:React.FC<React.HTMLProps<Element>> = (props) => {
    console.log(props)
    // props.type style 带背景建议时间 style2不带背景简易时间
  const [minutes, setminutes] = useState(getNowFormatDate('mm'));
  const [hour, sethour] = useState(getNowFormatDate('hh'));
    setInterval(() => {
        setminutes(getNowFormatDate('mm'))
        sethour(getNowFormatDate('hh'))
    },1000)
    return (
       <div>
            {
                props.type === 'style1' && 
                <div className='time_local_style1'>
                    <p>{getNowFormatDate('mo')}/{getNowFormatDate('dd')}</p>
                    <p>{getWeekDate()}</p>
                    <h4>{hour}:<i>{minutes}</i></h4>
                </div>
            }
            {
                props.type === 'style2' && 
                <div className='time_local_style2'>
                    <p>{getNowFormatDate('yy')}/{getNowFormatDate('mo')}/{getNowFormatDate('dd')}</p>
                    <p>{getWeekDate()}</p>
                    <h4>{hour}:<i>{minutes}</i></h4>
                </div>
            }
       </div>
            
    )
}
export default TimeLocal